package arithmetic.leetCode.yi;

import java.util.HashSet;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * 给定一个整数数组，判断是否存在重复元素。
 * <p>
 * 输入: [1,2,3,1]
 * 输出: true
 * User: yilin
 * Date: 2019-07-31
 * Time: 15:07
 */
public class Duplicate {

    public boolean containsDuplicate(int[] nums) {
        HashSet<Integer> set = new HashSet<>();
        for (int num : nums) {
            set.add(num);
        }
        return set.size() != nums.length;
    }
}
